import pdfMake from 'pdfmake/build/pdfmake'
// import pdfFonts from './font'
import loadScript from './loadScriptAsync'

const url = 'http://cdn.ayotrust.com/upload/2020-06-19/6109/font.js'
loadScript(url,() => {
    pdfMake.vfs = window.pdfMake.vfs;
    pdfMake.fonts = {
        Roboto: {
            normal: 'Roboto-Regular.ttf',
            bold: 'Roboto-Medium.ttf',
            italics: 'Roboto-Italic.ttf',
            bolditalics: 'Roboto-Italic.ttf'
        },
        msyh: {
            normal: '微软雅黑.ttf',
            bold: '微软雅黑.ttf',
            italics: '微软雅黑.ttf',
            bolditalics: '微软雅黑.ttf',
        }
    };
})


export default {
    open(pdf) {
        pdfMake.createPdf(pdf).open();
    },
    print(pdf) {
        pdfMake.createPdf(pdf).print();
    },
    download(pdf) {
        pdfMake.createPdf(pdf).download();
    }
}